package num73;

import java.util.HashMap;

/**
 * 73. 矩阵置零
 *
 * 题目： https://leetcode-cn.com/problems/set-matrix-zeroes
 *
 * 三叶姐题解： https://leetcode-cn.com/problems/set-matrix-zeroes/solution/xiang-jie-fen-san-bu-de-o1-kong-jian-jie-dbxd/
 *
 * me
 */
class Solution {
    public void setZeroes(int[][] matrix) {
        int row = matrix.length;
        int column = matrix[0].length;

        HashMap<Integer, Integer> rowMap = new HashMap<>();
        HashMap<Integer, Integer> columnMap = new HashMap<>();

        for (int i = 0; i < row; i++) {
            for (int j = 0; j < column; j++) {
                if (matrix[i][j] == 0) {
                    rowMap.put(i, j);
                    columnMap.put(j, i);
                }
            }
        }

        for (Integer integer : rowMap.keySet()) {
            int t = integer;
            for (int i = 0; i < column; i++) {
                matrix[t][i] = 0;
            }
        }

        for (Integer integer : columnMap.keySet()) {
            int t = integer;
            for (int i = 0; i < row; i++) {
                matrix[i][t] = 0;
            }
        }
    }
}
